import Ember from 'ember';

export default Ember.Component.extend({
  checkState: Ember.computed('selectedState', function() {
    var st = this.get('selectedState');

    if (st.all) {
      return 'fa-check-square-o';
    } else if (st.none) {
      return 'fa-square-o';
    } else {
      return 'fa-minus-square-o';
    }
  }),
  actions: {
    itemSelectChange() {
      var st = this.get('selectedState'),
        isPojo = this.get('isPojo'),
        modellist = this.get('modellist'),
        select = true;

      if (st.all || st.some) {
        select = false;
      }
      modellist.forEach((it) => {
        if (isPojo) {
          it.isSelected = select;
        } else {
          it.set('isSelected', select);
        }
      });
    }
  }
});
